<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="取消">
<!--    <datalib-logic-table-form ref="realForm" @ok="submitCallback" :currSelectedType="currSelectedType" :disabled="disableSubmit"></datalib-logic-table-form>-->
    <step-form ref="stepAddForm" v-if="showStepForm === true" :currSelectedType="currSelectedType"></step-form>
    <datalib-logic-table-info v-if="showInfo === true" ref="infoForm" :currSelectedType="currSelectedType"></datalib-logic-table-info>
  </j-modal>
</template>

<script>

  import StepForm from '@views/dscloud/dblib/logictable/stepForm/StepForm.vue'
  import datalibLogicTableInfo from './DatalibLogicTableInfo.vue'
  export default  {
    name: 'DatalibLogicTableModal',
    components: {
      StepForm,
      datalibLogicTableInfo
    },
    props: {
      // 声明接收名为currSelected的prop
      currSelectedType: {
        type: Object, // 根据实际数据类型定义
        required: true, // 如果这个prop是必需的，可以设置为true
      },
    },
    data () {
      return {
        title:'',
        width:800,
        visible: false,
        showStepForm:false,
        showInfo:false,
      }
    },
    methods: {
      add () {
        this.visible=true
        this.showStepForm = true
        this.showInfo = false
        // this.$nextTick(()=>{
        //   this.$refs.realForm.add();
        // })
        this.$nextTick(()=>{
          this.$refs.stepAddForm.add();
        })
      },
      edit (record) {
        this.visible=true
        this.showStepForm = true
        this.showInfo = false
        this.$nextTick(()=>{
          this.$refs.stepAddForm.edit(record);
        })
      },
      info(record){
        this.visible=true
        this.showStepForm = false
        this.showInfo = true
        this.$nextTick(()=>{
          this.$refs.infoForm.info(record);
        })
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        this.$emit('close');
        this.visible = false;
      },
      submitCallback(){
        this.$emit('ok');
        this.visible = false;
      },
      handleCancel () {
        this.close()
      }
    }
  }
</script>